# coding:utf-8
import pytesseract
from PIL import Image
import os


class VerifyCodeModify:
    def __init__(self):
        self.base_dir = 'ext/E1_generate_code'

    def run(self):
        _images = os.listdir(self.base_dir)
        for _image in _images[:1]:
            _image = '{}/{}'.format(self.base_dir, _image)
            print(_image)
            _im = Image.open(_image)
            _im = _im.convert('P')
            _data = pytesseract.image_to_string(_im)
            print(_data)


def main():
    vcm = VerifyCodeModify()
    vcm.run()


if __name__ == '__main__':
    main()
